package cn.wqk.rrtf.service;

import cn.wqk.rrtf.mapper.TeacherMapper;
import cn.wqk.rrtf.pojo.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class TeacherServiceImpl implements TeacherService{
    @Autowired
    TeacherMapper teacherMapper;
    @Override
    public List<Teacher> searchAllTeacher() {
        System.out.println("=====");
        System.out.println(teacherMapper.selectAllTeacher());
        return teacherMapper.selectAllTeacher();
    }

    @Override
    public Teacher searchTeacher(Teacher teacher) {
        if(teacherMapper.selectTeacher(teacher).size()==0){
            return null;
        }else {
            return teacherMapper.selectTeacher(teacher).get(0);
        }
    }

    @Override
    public Teacher searchTeacherByCourseId(Integer courseId) {
        return teacherMapper.selectTeacherByCourseId(courseId);
    }

    @Override
    public int updateTeacherInfo(Teacher teacher) {
        int result=teacherMapper.updateTeacher(teacher);
        return result;
    }
}
